package me.alex.lifecycledemo;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        getLifecycle().addObserver(new Lifecycle1());//日志查看过滤关键字  Lifecycle1
        getLifecycle().addObserver(new Lifecycle2());//日志查看过滤关键字  Lifecycle2
        startService(new Intent(MainActivity.this, LifeService.class)); //日志查看过滤关键字  LifeService
    }

    public void jump1(View view) {
        startActivity(new Intent(this, TwoActivity.class));
    }

    public void jump2(View view) {
        startActivity(new Intent(this, TwoActivity.class));
        finish();
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        stopService(new Intent(MainActivity.this, LifeService.class));
    }
}